package com.fayuan.nocv.controller;

import com.fayuan.nocv.entity.NocvGlobalData;
import com.fayuan.nocv.service.NocvGlobalDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/world")
public class NocvGlobalDataController {

    @Autowired
    private NocvGlobalDataService nocvGlobalDataService;

    @PostMapping("/saveData")
    @ResponseBody
    public void saveData(@RequestBody List<NocvGlobalData> list){

        for (NocvGlobalData data : list) {
            nocvGlobalDataService.save(data);
        }
    }

    @GetMapping("/queryWorld")
    @ResponseBody
    public List<NocvGlobalData>queryWorld(){

        return nocvGlobalDataService.list();
    }
}
